package com.cpit.qualitycontrol.service.impl;

import com.cpit.qualitycontrol.dao.UserToProductLineRepository;
import com.cpit.qualitycontrol.entity.UserToProductLine;
import com.cpit.qualitycontrol.service.UserToProductLineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by yanyq on 2018/04/28.
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class UserToProductLineServiceImpl implements UserToProductLineService {
    @Autowired
    private UserToProductLineRepository userToProductLineRepository;

    @Override
    public UserToProductLine addUserToProductLine(UserToProductLine userToProductLine) {
        return userToProductLineRepository.save(userToProductLine);
    }

    @Override
    public void deleteUserToProductLine(Integer userId) {
        userToProductLineRepository.deleteByUserId(userId);
    }

    @Override
    public List<UserToProductLine> findByUserId(Integer userId) {
        return userToProductLineRepository.findByUserId(userId);
    }
}
